package ui.robots_wicket;

import org.apache.wicket.Page;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.CompoundPropertyModel;

import unq.uis.robots.applicationsModels.PelearApplicationModel;

public class ResultadoCompetenciaPage extends WebPage{
	private static final long serialVersionUID = 1L;
	private Page mainPage;
	
	public ResultadoCompetenciaPage(Page mainPage,PelearApplicationModel pelearApplicationModel){
		super(new CompoundPropertyModel<PelearApplicationModel>(pelearApplicationModel));
		this.mainPage = mainPage;		
		this.agregarLabels();
		this.agregarBotones();
	}

	public void agregarLabels() {
		this.add(new Label("robotPropio.nombre"));
		
		if(((PelearApplicationModel)this.getDefaultModelObject()).getPelea().getResultado())
			this.add(new Label("resultado","ha obtenido una victoria =)"));
		else
			this.add(new Label("resultado","ha sido derrotado :("));
		this.add(new Label("pelea.ganancia"));
		this.add(new Label("pelea.porcentajeDesgaste"));
	}	

	public void agregarBotones() {
		this.add(new Link<String>("aceptar") {
			private static final long serialVersionUID = 1L;

			@Override
			public void onClick() {
				this.setResponsePage(mainPage);
			}
		});		
	}

}
